package com.lovo;

import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Currency;
import java.util.Locale;

public class Test01 {
    public String formatDate(String dateStr){
        LocalDate localDate = LocalDate.parse(dateStr);
        return localDate.format(DateTimeFormatter.ofPattern("yyyy年M月d日"));
    }
    public String snakeToCamle(String name){
        String [] names = name.split("_");
        String newName = "";
        for(int i = 0;i < names.length;i++){
            newName += Character.toUpperCase(names[i].charAt(0)) + names[i].substring(1);
        }
        return newName;
    }
    public String camleToSnake(String name){
        String newName = "";
        for(int i = 0;i < name.length();i++){
            char c = name.charAt(i);
            if(Character.isUpperCase(c) && i > 0){
                newName += "_" + c;
            }else{
                newName += c;
            }
        }
        return newName.toLowerCase();
    }
    public String currency(double d){
        DecimalFormat decimalFormat = new DecimalFormat(",###.00");
        return decimalFormat.format(d);
    }
    public static void main(String[] args) {
        Test01 test01 = new Test01();
        System.out.println(test01.formatDate("2020-01-01"));
        System.out.println(test01.snakeToCamle("my_first_name"));
        System.out.println(test01.camleToSnake("MyFirstName"));

        System.out.println(test01.currency(1234567890.1234));
    }
}
